package top.system.dept.pojo;

import com.fasterxml.jackson.annotation.JsonIgnore;
import org.springframework.format.annotation.DateTimeFormat;
import top.system.dept.utils.StringUtil;

import java.util.Arrays;
import java.util.Date;
import java.util.List;

public class Invoice {

    private Long id;

    // 开户行
    private String accountBank;

    // 发票编号
    private String invoiceId;

    // 发票金额
    private Double amount;

    // 开票时间
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date date;

    // 申请时间
    private Date applyDate;

    // 物资名称
    private List<InvoiceItem> items;

    // 文件保存位置
    @JsonIgnore
    private String filePaths;

    private String[] filePathArr;

    private Dept dept;

    private User applyUser;

    public String getFilePaths() {
        return this.filePaths;
    }

    public void setFilePaths(String filePaths) {
        this.filePaths = filePaths;
    }

    public Date getApplyDate() {
        return applyDate;
    }

    public void setApplyDate(Date applyDate) {
        this.applyDate = applyDate;
    }

    public Invoice(Long id, String accountBank, String invoiceId, Double amount, Date date, Date applyDate, List<InvoiceItem> items, Dept dept, User applyUser, String filePaths) {
        this.id = id;
        this.accountBank = accountBank;
        this.invoiceId = invoiceId;
        this.amount = amount;
        this.date = date;
        this.applyDate = applyDate;
        this.items = items;
        this.dept = dept;
        this.applyUser = applyUser;
        this.filePaths = filePaths;
    }

    public Dept getDept() {
        return dept;
    }

    public void setDept(Dept dept) {
        this.dept = dept;
    }

    public User getApplyUser() {
        return applyUser;
    }

    public void setApplyUser(User applyUser) {
        this.applyUser = applyUser;
    }

    @Override
    public String toString() {
        return "Invoice{" +
                "accountBank='" + accountBank + '\'' +
                ", invoiceId='" + invoiceId + '\'' +
                ", amount=" + amount +
                ", date=" + date +
                ", applyDate=" + applyDate +
                ", items=" + items +
                ", filePaths='" + filePaths + '\'' +
                ", dept=" + dept +
                ", applyUser=" + applyUser +
                '}';
    }

    public Invoice() {
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getAccountBank() {
        return accountBank;
    }

    public void setAccountBank(String accountBank) {
        this.accountBank = accountBank;
    }

    public String getInvoiceId() {
        return invoiceId;
    }

    public void setInvoiceId(String invoiceId) {
        this.invoiceId = invoiceId;
    }

    public Double getAmount() {
        return amount;
    }

    public void setAmount(Double amount) {
        this.amount = amount;
    }

    public Date getDate() {
        return date;
    }

    public void setDate(Date date) {
        this.date = date;
    }

    public List<InvoiceItem> getItems() {
        return items;
    }

    public void setItems(List<InvoiceItem> items) {
        for (InvoiceItem item : items) {
            item.setInvoiceId(this.invoiceId);
        }
        this.items = items;
    }

    public String[] getFilePathArr() {
        return filePathArr;
    }

    public void setFilePathArr(String[] filePathArr) {
        this.filePathArr = filePathArr;
    }
}
